/**
 * 弹出 DIV 窗口
 */

( function( j )
{
	//----------------------------------------------------------------------------------------------------

	j.starwin = function()
	{
		var t = this;
		var $t, $m;
		var def = {
			width: 600,
			height: 400,
			color: '#333',
			background: '#d0d0d0'
		};
		var html = "<div id='__DIV_WINDOW_MASK' style='display:block;position:absolute;background-color:#000;filter:alpha(opacity=20);opacity:0.2;'></div><div id='__DIV_WINDOW' style='position:absolute;border:3px solid #f9f9f9;background:#f0f0f0;-moz-border-radius: 6px;-khtml-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;box-shadow:1px 1px 15px #999;'></div>";

		t.init = function()
		{
			$( "body" ).append( html );
			$t = $( "#__DIV_WINDOW" );
			$m = $( "#__DIV_WINDOW_MASK" );
			$t.hide();
			$m.hide();

			$t.bind( "dblclick", function()
			{
				t.close();
			} );
		};

		t.open = function( w, h )
		{
			var bw = $( "body" ).width();
			var bh = $( "body" ).height();

			w = w != undefined ? w : def.width;
			h = h != undefined ? h : def.height;

			$t.width( w );
			$t.height( h );
			$m.width( bw );
			$m.height( bh );

			$m.offset( {
				left: 0,
				top: 0
			} );

			$t.offset( {
				left: ( bw - w ) / 2,
				top: ( bh - h ) / 2 * 0.8
			} );

			$m.show();
			$t.show();
		};

		t.close = function()
		{
			$t.hide();
			$m.hide();
		};

		t.html = function( url )
		{
			$t.load( url );
		};

		t.debug = function()
		{
			alert( def.width + ", " + def.height );
		};
	};

	j.starwin.e = null;

	j.starwin.init = function()
	{
		j.starwin.e = new j.starwin();
		j.starwin.e.init();
	};

	j.starwin.open = function( w, h )
	{
		j.starwin.e.open( w, h );
	};

	j.starwin.close = function()
	{
		j.starwin.e.close();
	};

	//----------------------------------------------------------------------------------------------------
} )( jQuery );
//
//$( "body" ).ready( function( e )
//{
//	$.starwin.init();
//	$.starwin.open();
//	$.starwin.e.html( '/oa/win/avatar.php' );
//} );
